package com.lcj.event;


import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * 异步监听日志事件
 *
 * @author Administrator
 */
@Slf4j
@Component
public class SysLogListener {
    @Async("eventListenerPool")
    @EventListener(SysLogEvent.class)
    public void saveSysLog(SysLogEvent event) {
        OptLogDTO sysLog = (OptLogDTO) event.getSource();

        log.info("虚拟线程：{}, 监听到日志操作事件：{} ", Thread.currentThread(), JSONUtil.toJsonStr(sysLog));

        //将日志信息保存到数据库...
    }
}